import 'package:easy_refresh/easy_refresh.dart';
import 'package:fluro/fluro.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:shenfuhui/config/config.dart';

import '../routers/routers.dart';
import '../views/dialog_manager.dart';

///
/// 我的团队
///
class MineTeam extends StatefulWidget {
  const MineTeam({Key? key}) : super(key: key);

  @override
  State<MineTeam> createState() => _MineTeamState();
}

class _MineTeamState extends State<MineTeam> {
  ///
  /// 返回普通的列表item
  ///
  Widget getListItem(String title, String subTitle) {
    return Container(
      height: 180.w,
      padding: EdgeInsets.symmetric(vertical: 22.w, horizontal: 20.w),
      decoration: BoxDecoration(
        border:
            Border(bottom: BorderSide(width: 3.w, color: Config.colorDivider)),
      ),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.start,
        children: [
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Container(
                //头像区
                margin: EdgeInsets.fromLTRB(0.w, 0.w, 0, 0),
                child: Row(
                  crossAxisAlignment: CrossAxisAlignment.center,
                  children: [
                    ClipOval(
                      child: Container(
                          width: 64.w,
                          height: 64.w,
                          color: (Config.colorWhite),
                          padding: EdgeInsets.all(3.w),
                          child: const CircleAvatar(
                            backgroundImage: NetworkImage(
                                'https://pic1.zhimg.com/v2-6438843a4cbae9184b935a75a5059ac6_1440w.jpg?source=172ae18b'),
                          )),
                    ),
                  ],
                ),
              ),
            ],
          ),
          Container(
            width: 560.w,
            margin: EdgeInsets.only(left: 20.w),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text(
                      "130****4545",
                      style: TextStyle(
                        fontSize: 24.w,
                        color: Config.colorText1,
                      ),
                    ),
                    Text(
                      "2023-02-05 02:02",
                      style: TextStyle(
                        fontSize: 22.w,
                        color: Config.colorText3,
                      ),
                    ),
                  ],
                ),
                Padding(padding: EdgeInsets.only(top: 12.w)),
                Row(
                  mainAxisAlignment: MainAxisAlignment.start,
                  children: [
                    Container(
                      decoration: BoxDecoration(
                        color: Config.colorMain,
                        borderRadius: BorderRadius.circular(20.w),
                      ),
                      padding:
                          EdgeInsets.symmetric(vertical: 4.w, horizontal: 10.w),
                      child: Text(
                        "个体消费商",
                        style: TextStyle(
                            fontSize: 18.sp, color: Config.colorWhite),
                      ),
                    ),
                    Container(
                      margin: EdgeInsets.only(left: 12.w),
                      decoration: BoxDecoration(
                        color: Config.colorMain,
                        borderRadius: BorderRadius.circular(20.w),
                      ),
                      padding:
                          EdgeInsets.symmetric(vertical: 4.w, horizontal: 10.w),
                      child: Text(
                        "一级合伙人",
                        style: TextStyle(
                            fontSize: 18.sp, color: Config.colorWhite),
                      ),
                    ),
                  ],
                ),
                Padding(padding: EdgeInsets.only(top: 15.w)),
                Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: [
                    Text(
                      "团队业绩：100",
                      style: TextStyle(
                        fontSize: 24.w,
                        color: Config.colorText1,
                      ),
                    ),
                    Text(
                      "团队人数：10",
                      style: TextStyle(
                        fontSize: 22.w,
                        color: Config.colorText1,
                      ),
                    ),
                  ],
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Config.colorBg2,
        appBar: AppBar(
          title: const Text('我的团队'),
          centerTitle: true,
        ),
        body: SizedBox(
          width: double.infinity,
          height: double.infinity,
          child: Stack(
            children: [
              Container(
                width: double.infinity,
                height: 290.w,
                padding: EdgeInsets.symmetric(vertical: 20.w, horizontal: 20.w),
                margin: EdgeInsets.fromLTRB(30.w, 30.w, 30.w, 0),
                decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.circular(12.w),
                ),
                child: Column(
                  children: [
                    Column(
                      mainAxisAlignment: MainAxisAlignment.spaceAround,
                      crossAxisAlignment: CrossAxisAlignment.center,
                      children: [
                        Row(
                          children: [
                            Text(
                              "我的级别身份",
                              style: TextStyle(
                                  fontSize: 24.sp, color: Config.colorText1),
                            ),
                            Container(
                              decoration: BoxDecoration(
                                color: Config.colorMain,
                                borderRadius: BorderRadius.circular(20.w),
                              ),
                              padding: EdgeInsets.symmetric(
                                  vertical: 4.w, horizontal: 10.w),
                              margin: EdgeInsets.only(left: 12.w),
                              child: Text(
                                "个体消费商",
                                style: TextStyle(
                                    fontSize: 18.sp, color: Config.colorWhite),
                              ),
                            ),
                            Container(
                              margin: EdgeInsets.only(left: 12.w),
                              decoration: BoxDecoration(
                                color: Config.colorMain,
                                borderRadius: BorderRadius.circular(20.w),
                              ),
                              padding: EdgeInsets.symmetric(
                                  vertical: 4.w, horizontal: 10.w),
                              child: Text(
                                "一级合伙人",
                                style: TextStyle(
                                    fontSize: 18.sp, color: Config.colorWhite),
                              ),
                            ),
                          ],
                        ),
                        Padding(
                          padding: EdgeInsets.only(top: 24.w),
                        ),
                        Divider(
                          color: Config.colorDivider,
                          height: 2.w,
                          thickness: 2.w,
                        ),
                        Padding(
                          padding: EdgeInsets.only(top: 15.w),
                        ),
                        Text(
                          "团队总业绩",
                          style: TextStyle(fontSize: 22.sp),
                        ),
                        Text(
                          "0.0000",
                          style: TextStyle(fontSize: 26.sp),
                        ),
                        Padding(
                          padding: EdgeInsets.only(top: 15.w),
                        ),
                        Divider(
                          color: Config.colorDivider,
                          height: 2.w,
                          thickness: 2.w,
                        ),
                        Padding(
                          padding: EdgeInsets.only(top: 15.w),
                        ),
                        Row(
                          mainAxisAlignment: MainAxisAlignment.spaceAround,
                          children: [
                            Column(
                              children: [
                                Text(
                                  "团队总人数",
                                  style: TextStyle(fontSize: 22.sp),
                                ),
                                Text(
                                  "0.0000",
                                  style: TextStyle(fontSize: 26.sp),
                                ),
                              ],
                            ),
                            Column(
                              children: [
                                Text(
                                  "今日新增业绩",
                                  style: TextStyle(fontSize: 22.sp),
                                ),
                                Text(
                                  "0.0000",
                                  style: TextStyle(fontSize: 26.sp),
                                ),
                              ],
                            ),
                          ],
                        ),
                      ],
                    ),
                  ],
                ),
              ),
              Container(
                  width: double.infinity,
                  height: double.infinity,
                  padding: EdgeInsets.symmetric(vertical: 0, horizontal: 0.w),
                  margin: EdgeInsets.only(
                      left: 30.w, right: 30.w, top: 345.w, bottom: 25.w),
                  decoration: BoxDecoration(
                    color: (Config.colorWhite),
                    borderRadius: BorderRadius.circular(12.w),
                  ),
                  child: EasyRefresh(
                    header: const MaterialHeader(),
                    footer: const MaterialFooter(),
                    onRefresh: () async {
                      await Future.delayed(const Duration(seconds: 1), () {
                        print('refresh');
                      });
                    },
                    onLoad: () async {
                      await Future.delayed(const Duration(seconds: 1), () {
                        print('load');
                      });
                    },
                    child: ListView(
                      // physics: const NeverScrollableScrollPhysics(),
                      padding:
                          EdgeInsets.symmetric(vertical: 1.w, horizontal: 1.w),
                      children: [
                        getListItem("", ""),
                        getListItem("", ""),
                      ],
                    ),
                  )),
            ],
          ),
        ));
  }
}
